#ifndef _SOMB_DAEMON_H_
#define _SOMB_DAEMON_H_

#include "somb_common.h"
#include "uthash.h"



struct somb_daemon_sub_ns;

struct somb_daemon_service_listener_info{

    struct somb_daemon_sub_ns *pstSubNs;
    uint32_t listener_flags;
};

struct somb_daemon_service_listened_subns
{
    struct somb_daemon_service_listener_info listener_info;
    struct somb_daemon_service_listened_subns *prev;
    struct somb_daemon_service_listened_subns *next;
};
typedef struct somb_daemon_service_list{
    uint32_t id;                    /* key */
    uint8_t type;
    E_SOMB_SERVICEID_STATUS status;
    struct somb_daemon_sub_ns *pstNsAddr; /*the service was provided by pstNsAddr*/
    struct somb_daemon_service_listened_subns *listener_sub_ns_list_head;/*the service was listened by  listener_sub_ns_list_head*/
    UT_hash_handle hh;         /* makes this structure hashable */
}ST_SOMB_DAEMON_SERVICE_LIST;


struct somb_daemon_subns_owned_service
{
    struct somb_daemon_service_list *pstService;
    struct somb_daemon_subns_owned_service *prev;
    struct somb_daemon_subns_owned_service *next;
};
typedef struct somb_daemon_sub_ns{
    uint32_t pid; // pid
    uint32_t id;//sub ns id
    SOMB_DAEMON_NS_STATUS status;
    uint32_t ref;
    int clientfd;//when client connect to somb_daemon, clientfd will be assigned with the value returned by accept
    char name[32];
    char addr[SOMB_ADDR_LEN];
    struct somb_daemon_subns_owned_service *owned_servicelist_head; /*th */
    //struct somb_daemon_sub_ns *next;/* make this structure as a list*/
    UT_hash_handle hh;         /* makes this structure hashable */
}ST_SOMB_DAEMON_SUB_NS;



#endif // _SOMB_DAEMON_H_
